package SceneTrigger

import (
	. "misc/Clojure/parse"
)

type EventInfo struct {
	EventName string
	TG        *Trigger
}
type IEvent interface {
	GetEventInfo() *EventInfo
	OnEventCondition() bool
}
type CreateEventFn func(args []Node) IEvent

var createEventFuncs map[string]CreateEventFn

func init() {
	createEventFuncs = make(map[string]CreateEventFn)
	createEventFuncs["GameLoad"] = createGameLoadEvent
	createEventFuncs["UnitDie"] = createUnitDieEvent
}
func CreateEvent(eventName string, args []Node) IEvent {
	ev := createEventFuncs[eventName](args)
	ev.GetEventInfo().EventName = eventName
	return ev
}

//GameLoad
type GameLoadEvent struct {
	EventInfo
}

func createGameLoadEvent(args []Node) IEvent {
	return &GameLoadEvent{}
}
func (g *GameLoadEvent) OnEventCondition() bool {
	return true
}
func (g *GameLoadEvent) GetEventInfo() *EventInfo {
	return &g.EventInfo
}

//UnitDie
type UnitDieEvent struct {
	EventInfo
}

func createUnitDieEvent(args []Node) IEvent {
	return &UnitDieEvent{}
}

func (this *UnitDieEvent) OnEventCondition() bool {
	return true
}

func (this *UnitDieEvent) GetEventInfo() *EventInfo {
	return &this.EventInfo
}
